#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFile>
#include <QHttp>
#include <QtGui>
#include <QMenu>
#include <QAction>
#include <QTranslator>
#include <QtGui>
#include <iostream>
#include <fstream>
#include <string>
#include <QRegExp>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent, QTranslator *applicationTranslator, QTranslator *qtTranslator);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);
    void checkRightNumbers();
    void makeGUI();
    void getSavedNumbers();
    void closeEvent(QCloseEvent *);
    QTranslator *applicationTranslator;
    QTranslator *qtTranslator;

private:
    Ui::MainWindow *ui;
    int _row1[7];
    int _row2[7];
    int _row3[7];
    int _row4[7];
    int _row5[7];
    int _row6[7];
    int _row7[7];
    int _row8[7];
    int _row9[7];
    int _row10[7];
    int _winnerNumbers[7];
    int _additionNumbers[3];
    int* correctNumbersCounter;
    int* correctAdditionNumbersCounter;
    int _numberOfRowsToCheck;
    int _httpGetId;

    bool _downloadedPrizesFromInternet;
    bool _anythingChanged;
    bool _languageNorwegian;

    QHttp _getLottoHttp;
    QHttp _getJokerHttp;
    QFile *_file;
    QMenu *_menuLanguage;
    QMenu *_menuWindow;
    QMenu *_helpMenuWindow;
    QAction *_changeToEnglish;
    QAction *_changeToNorwegian;
    QAction *_saveNumbers;
    QAction *_restartApp;
    QAction *_quitApp;
    QAction *_aboutMenu;
    QAction *_emptyLottoMenu;
    QAction *_emptyJokerMenu;
    QProgressDialog *_progressDialog;
    QString _lottoPrize[5];
    QString _jokerPrize[5];
    QString _lottoPrizeOutput;
    QString _jokerPrizeOutput;

    void doTranslateUi();
    void getLottoFileFromInternet(QString theurl);
    void getJokerFileFromInternet(QString theurl);
    void emptyLottoNumbers();
    void emptyPrize();
    void emptyLabels();
    void setDateField();

    void getNumbersFromRow1();
    void getNumbersFromRow2();
    void getNumbersFromRow3();
    void getNumbersFromRow4();
    void getNumbersFromRow5();
    void getNumbersFromRow6();
    void getNumbersFromRow7();
    void getNumbersFromRow8();
    void getNumbersFromRow9();
    void getNumbersFromRow10();

    void setRowsVisible();
    void setRow2Visible(bool state);
    void setRow3Visible(bool state);
    void setRow4Visible(bool state);
    void setRow5Visible(bool state);
    void setRow6Visible(bool state);
    void setRow7Visible(bool state);
    void setRow8Visible(bool state);
    void setRow9Visible(bool state);
    void setRow10Visible(bool state);

    void checkRow1();
    void checkRow2();
    void checkRow3();
    void checkRow4();
    void checkRow5();
    void checkRow6();
    void checkRow7();
    void checkRow8();
    void checkRow9();
    void checkRow10();

    void changeColorOnTxtJokerNumber1(QString numberInField);
    void changeColorOnTxtJokerNumber2(QString numberInField);
    void changeColorOnTxtJokerNumber3(QString numberInField);
    void changeColorOnTxtJokerNumber4(QString numberInField);
    void changeColorOnTxtJokerNumber5(QString numberInField);

    void getPlayerCardNumbersFromField();
    void getWinnerNumbersAndAdditionNumbersFromTextBoxes();
    void getAllNumbersFromTextBoxes();
    void prepareCounterArrays();
    void countCorrectMainNumbers();
    void countCorrectAdditionNumbers();
    void checkEveryRow();
    void changeColorOnInputBoxes(QString green, QString yellow, QString orange, QString white, bool anythingChanged2);



private slots:
    void on_deValidTo_dateChanged();
    void on_deValidFrom_dateChanged();
    void on_btnJokerNumbersFromPlayerCardNumber_clicked();
    void on_btnEmptyJokerNumbers_clicked();
    void on_btnEmptyLottoNumbers_clicked();
    void on_txtRow1Column7_textChanged();
    void on_txtRow1Column6_textChanged();
    void on_txtRow1Column5_textChanged();
    void on_txtRow1Column3_textChanged();
    void on_txtRow1Column2_textChanged();
    void on_txtRow1Column4_textChanged();
    void on_txtRow1Column1_textChanged();

    void on_txtRow2Column7_textChanged();
    void on_txtRow2Column6_textChanged();
    void on_txtRow2Column5_textChanged();
    void on_txtRow2Column3_textChanged();
    void on_txtRow2Column2_textChanged();
    void on_txtRow2Column4_textChanged();
    void on_txtRow2Column1_textChanged();

    void on_txtRow3Column7_textChanged();
    void on_txtRow3Column6_textChanged();
    void on_txtRow3Column5_textChanged();
    void on_txtRow3Column3_textChanged();
    void on_txtRow3Column2_textChanged();
    void on_txtRow3Column4_textChanged();
    void on_txtRow3Column1_textChanged();

    void on_txtRow4Column7_textChanged();
    void on_txtRow4Column6_textChanged();
    void on_txtRow4Column5_textChanged();
    void on_txtRow4Column3_textChanged();
    void on_txtRow4Column2_textChanged();
    void on_txtRow4Column4_textChanged();
    void on_txtRow4Column1_textChanged();

    void on_txtRow5Column7_textChanged();
    void on_txtRow5Column6_textChanged();
    void on_txtRow5Column5_textChanged();
    void on_txtRow5Column3_textChanged();
    void on_txtRow5Column2_textChanged();
    void on_txtRow5Column4_textChanged();
    void on_txtRow5Column1_textChanged();

    void on_txtRow6Column7_textChanged();
    void on_txtRow6Column6_textChanged();
    void on_txtRow6Column5_textChanged();
    void on_txtRow6Column3_textChanged();
    void on_txtRow6Column2_textChanged();
    void on_txtRow6Column4_textChanged();
    void on_txtRow6Column1_textChanged();

    void on_txtRow7Column7_textChanged();
    void on_txtRow7Column6_textChanged();
    void on_txtRow7Column5_textChanged();
    void on_txtRow7Column3_textChanged();
    void on_txtRow7Column2_textChanged();
    void on_txtRow7Column4_textChanged();
    void on_txtRow7Column1_textChanged();

    void on_txtRow8Column7_textChanged();
    void on_txtRow8Column6_textChanged();
    void on_txtRow8Column5_textChanged();
    void on_txtRow8Column3_textChanged();
    void on_txtRow8Column2_textChanged();
    void on_txtRow8Column4_textChanged();
    void on_txtRow8Column1_textChanged();

    void on_txtRow9Column7_textChanged();
    void on_txtRow9Column6_textChanged();
    void on_txtRow9Column5_textChanged();
    void on_txtRow9Column3_textChanged();
    void on_txtRow9Column2_textChanged();
    void on_txtRow9Column4_textChanged();
    void on_txtRow9Column1_textChanged();

    void on_txtRow10Column7_textChanged();
    void on_txtRow10Column6_textChanged();
    void on_txtRow10Column5_textChanged();
    void on_txtRow10Column3_textChanged();
    void on_txtRow10Column2_textChanged();
    void on_txtRow10Column4_textChanged();
    void on_txtRow10Column1_textChanged();

    void on_btnCheckJokerNumbers_clicked();
    void on_txtJokerNumber5_textChanged();
    void on_txtJokerNumber4_textChanged();
    void on_txtJokerNumber3_textChanged();
    void on_txtJokerNumber2_textChanged();
    void on_txtJokerNumber1_textChanged();
    void on_txtJokerWinnerNumber5_textChanged(QString numberInField);
    void on_txtJokerWinnerNumber4_textChanged(QString numberInField);
    void on_txtJokerWinnerNumber3_textChanged(QString numberInField);
    void on_txtJokerWinnerNumber2_textChanged(QString numberInField);
    void on_txtJokerWinnerNumber1_textChanged(QString numberInField);
    void on_btnJokerNumbers_clicked();
    void on_txtAdditionNumber3_textChanged(QString number);
    void on_txtAdditionNumber2_textChanged(QString number);
    void on_txtAdditionNumber1_textChanged(QString number);
    void on_txtWinnerNumber7_textChanged(QString number);
    void on_txtWinnerNumber6_textChanged(QString number);
    void on_txtWinnerNumber5_textChanged(QString number);
    void on_txtWinnerNumber4_textChanged(QString number);
    void on_txtWinnerNumber3_textChanged(QString number);
    void on_txtWinnerNumber2_textChanged(QString number);
    void on_txtWinnerNumber1_textChanged(QString number);
    void on_cmbNumberOfRows_currentIndexChanged(int index);
    void on_btnCheckNumbers_clicked();

    void removeJokerNumbers();
    void getLottoPrizeFromFile(bool);
    void getLottoNumbersFromFile(bool);
    void getJokerPrizeFromFile(bool);
    void getJokerNumbersFromFile(bool);
    void on_btnGetWinnerNumbersFromInternet_clicked();
    void languageSwitchToEnglish();
    void languageSwitchToNorwegian();
    void doEmpty();
    void saveToFile();
    void checkValidPlayCard();
    void checkWeekLeft();
    void about();
    void updateDataReadProgress(int bytesRead, int totalBytes);
};

#endif // MAINWINDOW_H
